﻿<!DOCTYPE html>
<html>
<head>
	<title>{$site_name}</title>
	<meta name="keywords" content="{$site_seo_keywords}" />
	<meta name="description" content="{$site_seo_description}">
	<meta name="author" content="ThinkCMF">
	<tc_include file="Public:head" />
	<link href="__PUBLIC__/js/artDialog/skins/default.css" rel="stylesheet" />
	<style>
		.new_box {padding-top: 15px;padding-bottom: 15px;}
		.lf_text {height: 92px;border-radius: 10px;border:1px solid #707070;font-size: 18px;line-height: 30px;padding: 10px 5px;margin-top: 18px;overflow-y:scroll;}
		.btnSubmit {width: 266px;margin:0 auto; margin-top: 50px;}
		.lf_text li{list-style: none;margin-bottom: 4px;}
		.lf_text ul,.lf_text li{padding: 0;margin:0;}
		.lf_text li:hover {
			background-color: #e0e0e4;
		}
		.btnSubmit .submit{width: 100px;height: 30px;border-radius: 10px;color: #fff;border:none;margin: 0 15px;}
		.btnSubmit .submit:first-child {background-color: #c8161d;}
		.btnSubmit .submit:last-child{background-color: #000232;}
		/*个人的中心布局样式调整*/
		.container {
			width: 1190px;
		}
		.row {
			margin-left: 0px;

		}
		.span3 {
			margin-left: 0;
			width: 280px;
		}
		.span9 {
			width: 830px;
			margin-left: 80px;
		}
		input{
			outline:none
		}
		/*
        .container .title{
            font-size: 16px;
            color: #000232;
            line-height: 48px;
            padding-left: 60px;
            border-bottom: 1px solid #676884;
            margin-bottom: 18px;
        }

       */
		/*个人的中心布局样式调整结束*/
	</style>
</head>
<body class="body-white" id="top">
<tc_include file="Public:nav" />

<div class="container tc-main">
	<div class="row">

		<!--左侧导航栏-->
		<div class="span3">
			<tc_include file="Public:usernav"/>
		</div>

		<!--右侧内容-->
		<div class="span9">

			<form method="post" action="{:U('portal/article/edit_post')}" class="form-horizontal js-ajax-forms" enctype="multipart/form-data" style="margin-top: 20px;">
				<input type="hidden" name="id" value="{$post.id}">
				<input type="hidden" name="post[id]" value="{$post.id}">
				<input type="text" style="width: 99%;border: none;border-bottom: solid 1px #000232;font-size: 18px;outline: none;" name="post[post_title]" required value="{$post.post_title}" placeholder="请输入标题"/>
				<div class="new_box">
					<if condition="!empty($judge_list)">
						<div class="lf_text">
							<ul>
								<volist name="judge_list" id="vo">
									<li>
										<p>原因：<span>{$vo.reason}</span> </p>
										<p>修改建议：<span>{$vo.suggest}</span></p>
									</li>
								</volist>
							</ul>
						</div>
					</if>

				</div>


				<div style="position: relative;clear: both;padding-top: 10px;">
					<textarea id="content_show" name="content_show">{$post.post_content}</textarea>
					<textarea id="post_content" name="post[post_content]" style="z-index: -1;position:absolute;top: 40px; max-width: 20px;">{$post.post_content}</textarea>
				</div>

				<div class="editorCenter">
					<div class="btnSubmit">
						<button type="submit" class="submit" data-status="0">提交稿件</button>
						<button type="button" class="submit" data-status="4">保存稿件</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- /container -->

<tc_include file="Public:footer" />
<tc_include file="Public:scripts" />

<script type="text/javascript" src="__PUBLIC__/js/artDialog/artDialog.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/layer/layer_1.js"></script>
<script>

	var loading = false;

	$(function(){

		$('.submit').click(function () {
			$(this).addClass('click').siblings().removeClass('click');
			$('form.js-ajax-forms').submit();
		});

		editorcontent = new baidu.editor.ui.Editor({
			initialFrameWidth   : '100%',   //设置编辑器宽度
			initialFrameHeight  : '400',    //设置编辑器高度
			scaleEnabled        : true,     //设置不自动调整高度
		});
		editorcontent.render('content_show');

		// 监听编辑区内容变化
		editorcontent.addListener( 'selectionchange', function() {
			var content = editorcontent.getContent();
			$('#post_content').val(content); // 方便表单提交验证
		});


		Wind.use('validate', 'ajaxForm', function() {

			var form = $('form.js-ajax-forms');

			//ie处理placeholder提交问题
			if ($.browser && $.browser.msie) {
				form.find('[placeholder]').each(function() {
					var input = $(this);
					if (input.val() == input.attr('placeholder')) {
						input.val('');
					}
				});
			}

			//表单验证开始
			form.validate({
				//是否在获取焦点时验证
				onfocusout : false,
				//是否在敲击键盘时验证
				onkeyup : false,
				//当鼠标掉级时验证
				onclick : false,
				// 错误展示
				showErrors : function(errorMap, errorArr) {
					//errorMap {'name':'错误信息'}
					//errorArr [{'message':'错误信息',element:({})}]
					try {
						$(errorArr[0].element).focus();
						layer.msg(errorArr[0].message);
					} catch (err) {

					}
					this.defaultShowErrors();
				},
				//指明错误放置的位置
				errorPlacement: function(error, element) {
				},
				//验证规则
				rules : {
					'post[post_title]' : {
						required : 1
					},
					'post[post_content]' : {
						required : 1
					},
				},
				//验证未通过提示消息
				messages : {
					'post[post_title]' : {
						required : '请输入文章标题'
					},
					'post[post_content]' : {
						required : '请输入文章内容'
					},
				},
				//验证通过，提交表单
				submitHandler : function(forms) {

					if (loading) {
						layer.load();
						return;
					}
					loading = true;

					var status = $('.click').attr('data-status');

					$(forms).ajaxSubmit({
						url : form.attr('action') + "&status=" + status, //按钮上是否自定义提交地址(多按钮情况)
						dataType : 'json',
						success : function(data, statusText, xhr, $form) {
							layer.msg(data.info);
							if (data.status == 1) {

								setTimeout(function () {
									window.location.href = "{:U('portal/article/user_article')}" + "&status=" + status;
								}, 1000);
							}
							loading = false;
						}
					});
				}
			});
		});
	});
</script>

<!--slide侧边栏动画-->
<script>
	$(function () {
		setTimeout(anim,500);
		function anim(){
			$(".animate_add").find(".menu_main").animate({
				marginLeft:'-90px'
			},300);
			$(".animate_add").find(".menu_list").animate({
				height:"36px",
				paddingTop:'12px'
			},300);
			$(".animate_add").find(".tab_article").addClass("active");
		}
	})
</script>
</body>
</html>